package testenum;

import java.lang.reflect.Constructor;
public class testReflectEnum {
    public static void reflectPrivateConstructor() {
        try {
            Class<?> classStudent = Class.forName("testenum.testEnum");
            Constructor<?> declaredConstructorStudent =
                    classStudent.getDeclaredConstructor(String.class,int.class,int.class,String.class);
            declaredConstructorStudent.setAccessible(true);
            Object objectStudent = declaredConstructorStudent.newInstance("父类参数",111,666,"绿色");
            testEnum testEnum = (testEnum) objectStudent;
            System.out.println("获得枚举的私有构造函数："+testEnum);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    public static void main(String[] args) {
        reflectPrivateConstructor();
    }

}
